#include "person.h"

#include <QTextStream>

Person::Person(QString firstName,
               QString lastName,
               int age,
               Gender gender,
               QString city,
               QString state,
               bool clubMember) :
    mFirstName(firstName),
    mLastName(lastName),
    mAge(age),
    mGender(gender),
    mCity(city),
    mState(state),
    mMember(clubMember)
{

}

Person::~Person()
{
}

QString Person::name()
{
    QString name;
    if (!mFirstName.isEmpty() && !mLastName.isEmpty())
    {
        QTextStream(&name) << mFirstName << " "
                             << mLastName;
    }
    else if (!mLastName.isEmpty())
    {
        name = mLastName;
    }
    else if (!mFirstName.isEmpty())
    {
        name = mFirstName;
    }
    return name;
}

QString Person::genderStr()
{
    QString g("?");
    if (mGender == Person::Male)
        g = "M";
    if (mGender == Person::Male)
        g = "F";
    return g;
}

Person::Gender Person::gender()
{
    return mGender;
}

QString Person::key()
{
    QString keystr;
    QString g;
    if (mGender == Person::Male)
        g = "M";
    else
        g = "F";
    QTextStream(&keystr) << mFirstName << " "
                         << mLastName << " "
                         << "(" << g << "-" << mAge <<") "
                         << mCity << "," << mState;
    return keystr;
}
